<template>
  <div class="Drawer">
    <div class="contentBody">
      <!-- 外部容器 -->
      <slot name="contentBody" />
    </div>
    <div class="drawerBox" :style="style">
      <div class="controlBar">
        <i class="el-icon-arrow-up" @click="open" v-show="isOpen"></i>
        <i class="el-icon-arrow-down" @click="down" v-show="!isOpen"></i>
      </div>
      <!-- 抽屉内容器 -->
      <div class="drawerBody">
        <slot name="drawerBody" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Drawer',
  components: {},
  props: {},
  data() {
    return {
      isOpen: true,
      style: {},
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    open() {
      this.style = {
        height: '400px',
      };
      setTimeout(() => {
        this.isOpen = false;
      }, 900);
    },
    down() {
      this.style = {
        height: '10%',
      };
      setTimeout(() => {
        this.isOpen = true;
      }, 900);
    },
  },
};
</script>

<style scoped lang="less">
.Drawer {
  height: 100%;
  overflow: hidden;
  position: relative;
  .contentBody {
    height: 90%;
    background-color: pink;
  }
  .drawerBox {
    width: 100%;
    height: 10%;
    background-color: #fff;
    box-sizing: border-box;
    border: 1px solid black;
    padding: 10px;
    position: absolute;
    bottom: 0px;
    transition: height 1s;
    .controlBar {
      height: 16px;
      text-align: center;
      position: absolute;
      top: -21px;
      left: 50%;
      right: 50%;
      i {
        color: white;
        box-sizing: border-box;
        border: 1px solid black;
        border-radius: 50% 50% 0 0;
        background-color: #405b96;
        width: 50px;
        height: 20px;
        cursor: pointer;
      }
    }
    .drawerBody {
      height: 100%;
      background-color: white;
    }
  }
}
</style>
